<template>
  <!-- <view class="order-model" style="background: #fff;" v-if="goods">
		<view class="goods-item">
			<view class="goods-img">
				<image :src="goods.goods_pic.pic_url" mode="aspectFit"></image>
			</view>
			<view class="goods-info">
				<view class="">
					{{goods.name}}
				</view>
				<view
				style="font-size: 24rpx;color: #888;margin-right: 20rpx;display: inline-block"
				v-for="(attr, attr_index) in goods.attr" :key="attr_index">
					{{attr.attr_group_name}}：{{attr.attr_name}}
				</view>
				<view class="flex-grow-1 flex-between" style="text-align: right">
					<view>×{{goods.num}}</view>
				</view>
			</view>
		</view>
	</view> -->
  <view class="goods-section">
    <!-- 多商品banner -->
    <!-- <view class="list-item-center-one" v-if="false">
      <scroll-view :scroll-x="true">
        <image
          :src="goodsItem.goods_pic"
          mode="aspectFill"
          v-for="(goodsItem, goodsIndex) in orderitem.goods_list"
          :key="goodsIndex"
        ></image>
        <image
          :src="goodsItem.goods_pic"
          mode="aspectFill"
          v-for="(goodsItem, goodsIndex) in orderitem.goods_list"
          :key="goodsIndex"
        ></image>
      </scroll-view>
      <view>
        <view class="order-rightSide">
          <view>
            <view class="order-price">
              <text>￥</text>
              <text>{{ orderitem.pay_price | priceBeforeZero }}</text>
              <text>{{ orderitem.pay_price | priceAfterZero }}</text>
            </view>
            <view>{{$t('order.total1')}}{{ orderitem.goods_list.length }}{{$t('order.total2')}}</view>
          </view>
        </view>
      </view>
    </view> -->

    <!-- 单商品banner -->
    <!-- <view class="list-item-center-two">
      <view class="list-good-item">
        <image :src="goods.goods_pic.pic_url" mode="aspectFill"></image>
        <view class="goods-info">
          <view class="goods-name">{{ goods.name }}</view>
          <view class="goods-sku">
            <view
              style="
                font-size: 24rpx;
                color: #888;
                margin-right: 20rpx;
                display: inline-block;
              "
              v-for="(attr, attr_index) in goods.attr"
              :key="attr_index"
            >
              {{ attr.attr_group_name }}：{{ attr.attr_name }}
            </view>
          </view>
          <view class="goods-price">
            <text>￥</text>
            <text>{{ goods.total_price | priceBeforeZero }}</text>
            <text>{{ goods.total_price | priceAfterZero }}</text>
          </view>
        </view>
      </view>
    </view> -->

    <view class="title">{{$t('mdAdmin.salesOut')}}</view>
    <view class="goodsList">
      <view class="goodItem" v-for="(item, index) in goods" :key="index">
        <view class="pic">
          <image :src="item.goods_pic"></image>
        </view>
        <view class="goods-info">
          <view class="goods-name">{{ item.name }}</view>
          <view class="goods-sku">
            <view class="skuList">
              <text
                class="sku"
                v-for="(sku, skuIndex) in item.attr"
                :key="skuIndex"
                >{{ sku.attr_group_name }}{{ sku.attr_name
                }}{{
                  skuIndex == item.attr.length - 1 ? "" : "，"
                }}</text
              >
            </view>
            <test class="count">×{{ item.num }}</test>
          </view>
          <view class="goods-price">
            <text>￥</text>
            <text>{{ item.total_price | priceBeforeZero }}</text>
            <text>{{ item.total_price | priceAfterZero }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    goods: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  filters: {
    priceBeforeZero(val) {
      if (val.indexOf(".") < 0) return `${val}.`;
      return val.substr(0, val.indexOf("."));
    },
    priceAfterZero(val) {
      if (val.indexOf(".") < 0) return "00";
      return val.substr(val.indexOf("."), val.lenhth);
    },
  },
  methods: {},
};
</script>

<style lang="scss"scoped>
.order-model {
  .flex-grow-1 {
    display: flex;
  }
  .flex-between {
    justify-content: space-between;
  }
  .goods-item {
    display: flex;
    .goods-img {
      width: 200rpx;
      height: 200rpx;
      overflow: hidden;
      > image {
        width: 200rpx;
        height: 200rpx;
      }
    }
    .goods-info {
      width: 550rpx;
      padding-left: 16rpx;
      box-sizing: border-box;
    }
  }
}

.goods-section {
  width: 100%;
  background: #ffffff;
  padding: 0 36rpx;
  .title {
    padding-top: 36rpx;
    font-size: 30rpx;
    color: #262626;
    font-weight: 600;
    font-family: PingFang SC;
  }
  .goodItem {
    padding: 30rpx 0;
    border-bottom: 1px solid #f8f8f8;
    display: flex;
    .pic {
      width: 166rpx;
      height: 166rpx;
      min-width: 166rpx;
      border-radius: 10rpx;
      overflow: hidden;
      background-color: #f2f2f2;
      image {
        width: 100%;
        height: 100%;
      }
    }
    .goods-info {
      flex: auto;
      margin-left: 20rpx;
      width: 0;
      .goods-name {
        font-size: 26rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #262626;
        line-height: 32rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
      }

      .goods-sku {
        font-size: 22rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8c8c8c;
        line-height: 26rpx;
        margin: 15rpx 0 17rpx 0;
        display: flex;
        justify-content: space-between;
        .skuList {
          max-width: 326rpx;
          text-overflow: -o-ellipsis-lastline;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          line-clamp: 2;
          -webkit-box-orient: vertical;
        }
      }

      .goods-price {
        color: #262626;
        font-size: 22rpx;
        display: flex;
        align-items: baseline;
        font-weight: 600;
        text:nth-child(1) {
          font-size: 24rpx;
        }
        text:nth-child(2) {
          font-size: 32rpx;
          
        }
        text:last-child {
          font-size: 24rpx;
        }
      }
    }
  }
}

.list-item-center-one {
  margin-top: 30rpx;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;

  scroll-view {
    overflow-x: scroll;
    flex: 1;
    white-space: nowrap;

    image {
      margin-right: 10rpx;
      width: 160rpx;
      height: 160rpx;
      border-radius: 10rpx;
      display: inline-block;
    }
    image:last-child {
      margin-right: 170rpx;
    }
  }

  .order-rightSide {
    width: 200rpx;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    right: 0;
    top: 0;
    z-index: 11;
    background: linear-gradient(
      90deg,
      rgba(255, 255, 255, 0),
      #ffffff,
      #ffffff
    );

    view:first-child {
      display: flex;
      flex-direction: column;
      text-align: right;
      width: 100%;

      .order-price {
        font-weight: bold;
        font-size: 34rpx;
        color: #262626;
        flex-direction: initial;
        align-items: baseline;
        justify-content: flex-end;

        text:first-child {
          font-size: 22rpx;
        }
        text:nth-child(2) {
          font-size: 34rpx;
        }
        text:last-child {
          font-size: 22rpx;
        }
      }
      view:last-child {
        margin-top: 4rpx;
        font-size: 24rpx;
        color: #8f8f8f;
      }
    }
  }
}
.list-item-center-two {
  margin-top: 30rpx;

  .list-good-item {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;

    image {
      width: 160rpx;
      height: 160rpx;
      border-radius: 10rpx;
      margin-right: 24rpx;
    }

    .goods-info {
      flex: 1;
      max-width: 480rpx;

      .goods-name {
        font-size: 26rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #262626;
        line-height: 32rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }

      .goods-sku {
        font-size: 22rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8c8c8c;
        line-height: 26rpx;
        margin: 15rpx 0 17rpx 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .goods-price {
        color: #262626;
        display: flex;
        align-items: baseline;
        font-weight: 600;
        text:nth-child(1) {
          font-size: 24rpx;
        }
        text:nth-child(2) {
          font-size: 32rpx;
        }
        text:last-child {
          font-size: 24rpx;
        }
      }
    }
  }
}
</style>
